﻿@using KPIS.GERP.SERVICE.Model
@model KPIS.GERP.SERVICE.Model.hrm_ps_commands

@{
    ViewBag.Title = "คำสั่งบรรจุ";
}

<div style="margin-left:100px; margin-bottom: 30px; float:left;">
<h2><span class="green">เพิ่ม</span> คำสั่งบรรจุ</h2>

@using (Html.BeginForm()) {
    @*@Html.AntiForgeryToken()*@
    @Html.ValidationSummary(true)

    <h4 class="header">แบบฟอร์มคำสั่งบรรจุ</h4>

    <div class="detail">
        <table class="info">
            <tr>
                <td class="editor-label">

                </td>
                <td class="editor-field">
                    <span style="visibility:collapse">@Html.RadioButtonFor(model => model.cmd_flag, "1") คำสั่งหน่วยงาน</span>
                    @Html.RadioButtonFor(model => model.cmd_flag, "2") คำสั่งสรพ.
                    @Html.RadioButtonFor(model => model.cmd_flag, "3") คำสั่งกระทรวง
                    @Html.ValidationMessageFor(model => model.cmd_flag)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.cmd_type_seq)
                </td>
                <td class="editor-field">
                    @(Html.Telerik().ComboBoxFor(m => m.cmd_type_seq)
                        .BindTo(new SelectList(new GERPContext().hrm_ps_command_types.Where(m => m.cmd_group_seq == 1 && m.record_status != "D").ToList(), "cmd_type_seq", "cmd_type_name"))
                        //.SelectedIndex(Model != null ? (Model.cmd_type_seq != null ? Model.cmd_type_seq.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                    )
                    @Html.ValidationMessageFor(model => model.cmd_type_seq)
                </td>
            </tr>

            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.cmd_name)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.cmd_name)
                    @Html.ValidationMessageFor(model => model.cmd_name)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.cmd_ref_no)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.cmd_ref_no)
                    @Html.ValidationMessageFor(model => model.cmd_ref_no)
                </td>
            </tr>

            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.cmd_descr)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.cmd_descr)
                    @Html.ValidationMessageFor(model => model.cmd_descr)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.emp_type_seq)
                </td>
                <td class="editor-field">
                    @(Html.Telerik().ComboBoxFor(m => m.emp_type_seq)
                        .BindTo(new SelectList(new GERPContext().hrm_ps_employee_types.Where(m => m.record_status != "D").ToList(), "emp_type_seq", "emp_type_name"))
                        //.SelectedIndex(Model != null ? (Model.emp_type_seq != null ? Model.emp_type_seq.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                    )
                    @Html.ValidationMessageFor(model => model.emp_type_seq)
                </td>
            </tr>

            @*<tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.penalty_seq)
                </td>
                <td class="editor-field">
                    @(Html.Telerik().ComboBoxFor(m => m.penalty_seq)
                        .BindTo(new SelectList(new GERPContext().hrm_dc_penalty.ToList(), "pen_seq", "pen_name"))
                        //.SelectedIndex(Model != null ? (Model.penalty_seq != null ? Model.penalty_seq.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                    )
                    @Html.ValidationMessageFor(model => model.penalty_seq)
                </td>
            </tr>*@
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.remarks)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.remarks)
                    @Html.ValidationMessageFor(model => model.remarks)
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <h3>หัวรายงาน</h3>
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.cmd_rpt_date)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.cmd_rpt_date)
                    @Html.ValidationMessageFor(model => model.cmd_rpt_date)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.rpt_header)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.rpt_header)
                    @Html.ValidationMessageFor(model => model.rpt_header)
                </td>
            </tr>
        </table>
        
    <p id="pnlCommand1">
        <input type="submit" value="บันทึก" />&nbsp;&nbsp;@Html.ActionLink("ย้อนกลับ", "Index")
    </p>
    </div>
}
    
</div>

@section Scripts {
    @*@Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")
    @Styles.Render("~/Content/themes/base/css")*@

    <script type="text/javascript" >
        jQuery(function ($) {
            $("input#approved_type").change(function () {
                $("#divApproverInternal").toggle(this.value == "1");
                $("#divApproverExternal").toggle(this.value == "2");
            });
            $("input#approved_type:checked").change();
        });

        function ddlApprovedChange(e) {
            $.getJSON('@Url.Action("GetPosition", "Employee")', { 'id': e.value }, function (data) {
                $("input#approved_positions").val(data.pos_name);
            });
        }

        jQuery(function ($) {
            $("[type='submit']").click(function () {
                var ans = confirm("ต้องการบันทึก ใช่หรือไม่?");

                if (!ans) return false;
            })
        })

        jQuery(function ($) {
            $(".datepicker").datepicker({
                showOn: "focus",
                buttonImage: "../../Images/Icons/calendar.png",
                buttonImageOnly: true,
                dateFormat: "dd/mm/yy",
                //isBE: true
            });
        });
    </script>
}
